﻿using ERPEF.Model;
using ERPIService;
using Microsoft.EntityFrameworkCore;
using S4Project;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ERPService
{
    public class inv_WarehouseService : inv_WarehouseIService
    {
        private readonly MyDbContext MyDbContext;
        public inv_WarehouseService(MyDbContext myDb)
        {
            this.MyDbContext = myDb;
        }

        public Task<int> Add(inv_WarehouseInven inv_WarehouseInven)
        {
            MyDbContext.inv_WarehouseInven.Add(inv_WarehouseInven);
            return MyDbContext.SaveChangesAsync();
        }

        public async Task<List<inv_goods_inventory>> GetInventoryByWarehouseAsync(string igi_warehouse)
        {
            return await MyDbContext.inv_goods_inventory
                .Where(igi => igi.igi_warehouse == igi_warehouse)
                .ToListAsync();
        }

        public Task<int> Update(inv_WarehouseInven inv_WarehouseInven)
        {
            MyDbContext.inv_WarehouseInven.Update(inv_WarehouseInven);
            return MyDbContext.SaveChangesAsync();
        }

        public Task<int> Add_C(inv_WarehouseInven_C data)
        {
            MyDbContext.inv_WarehouseInven_C.Add(data);
            return MyDbContext.SaveChangesAsync();
        }
        public Task<int> Update_C(inv_WarehouseInven_C data)
        {
            MyDbContext.inv_WarehouseInven_C.Update(data);
            return MyDbContext.SaveChangesAsync();
        }
    }
}
